#pragma once
#include "Global References\Globals.h"
#include "World/Entity/Entity.h"
#include "../../Global References/timer.h"
#include "Entity\Local References.h"

///////////////////////////////////////////////////////////
//This is the Animation class, it handles all ins and outs of animation
//Contains the Bodypartinformation, the frames, the sequences and the animation engine itself
//Added by Tyler Lawton on 1/19/2012
///////////////////////////////////////////////////////////
struct BodypartInfo
{
	int bodypart;
	Vector3D targetPosition, targetRotation;
	BodypartInfo(){bodypart = -1;}
	void init(Vector3D p_TP, Vector3D p_TR, int p_bodypart){targetPosition = p_TP; targetRotation = p_TR; bodypart = p_bodypart;}
};
struct Frame
{
	int frameNumber;
	BodypartInfo toTween[Entity::e_TotalBPs];
	Frame(){frameNumber = -1;}
	void createframe(int p_fnumber, BodypartInfo p_toTween[]);
};
struct Sequence
{
	stopWatch frameInterval;
	int typeofSequence;
	int animationLength;
	bool activePieces[Entity::e_TotalBPs];
	Frame* animChain;

	void init(char* filename);
	void Execute(int& currFrame, XYZ* CurrPos, XYZ* CurrRots, int lastXDir);
	Sequence();
	~Sequence();
};
class Animation
{
public:
	Animation();
	~Animation();
protected:
	bool activePieces[Entity::e_TotalBPs];
	Vector<Sequence> AnimationList;
	bool m_bInitialized;
	void fillinFalses(XYZ* currPos, XYZ* currRots, int p_lastXDir);
	bool parseActiveSequences(int index, bool p_ActiveAnimations[], int p_currentFrames[], XYZ* CurrPos, XYZ* CurrRots, int p_lastXDir);
public:
	void getActivePieces(bool p_activePieces[]);
	bool Update(bool p_ActiveAnimations[], int p_currentFrames[], XYZ* currPos, XYZ* currRots, int p_lastXDir);
	void init();
};
